{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "3e424666",
   "metadata": {},
   "source": [
    "-----------\n",
    "\n",
    "\n",
    "\n",
    "------"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "5258b59d",
   "metadata": {},
   "source": [
    "# 本周内容\n",
    "> 1. 有序的数据结构之列表\n",
    "> 2. 用户输入\n",
    "> 3. 关于格式化文本信息"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "41e23942",
   "metadata": {},
   "outputs": [],
   "source": [
    "网三_01_name = \"Marry\"\n",
    "# 思考：如果想一个变量存放一个班同学的名字，该怎么办？\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "a00d2614",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "H,M,J,K\n"
     ]
    }
   ],
   "source": [
    "网三_name_list = \"H,M,J,K\"\n",
    "print(网三_name_list)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "739ab914",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'M'"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 思考：处理数据会不会比较麻烦？\n",
    "网三_name_list[2:3]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "76260392",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "7"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 思考3：我想知道这个名单有多少个人名？\n",
    "len(网三_name_list)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "21e3ab9f",
   "metadata": {},
   "source": [
    "## 1. 引入列表的概念\n",
    "* \n",
    "> 注释：我们已经学习了 数值 和 字符，list可以放数值和字符，但是通常要么一起放数值，要么一起放字符串。\n",
    "\n",
    "> 总结一些通用的有序数据结构的方法：\n",
    ">> 1. 取值：通过索引值取出对应的内容\n",
    ">> 2. 切片：通过索引值区间取出对应的一些内容\n",
    ">> 3. in可以查看成员对象是否存在\n",
    "\n",
    "> 列表的一些方法："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "d568b0dc",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[1, 2, 3, 4] <class 'list'>\n"
     ]
    }
   ],
   "source": [
    "a = [1,2,3,4]\n",
    "print(a,type(a))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "53980635",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['H', 'M', 'J', 'K'] <class 'list'>\n"
     ]
    }
   ],
   "source": [
    "网三_name_list = [\"H\",\"M\",\"J\",\"K\"]\n",
    "print(网三_name_list,type(网三_name_list))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "7856fd27",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'M'"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 取出 网三_name_list 中第一位同学的名字\n",
    "网三_name_list[1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "82f5f8a5",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "网三： H\n",
      "网三： M\n",
      "网三： J\n",
      "网三： K\n"
     ]
    }
   ],
   "source": [
    "网三_name_list = [\"H\",\"M\",\"J\",\"K\"]\n",
    "for i in 网三_name_list:\n",
    "    print(\"网三：\",i)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "58a9886b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# in 可以查询数据是否存在\n",
    "\"M\" in 网三_name_list"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "ccc96fa2",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 关于运算法则\n",
    "网三_name_list_转专业 = [\"Y\",\"G\"]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "3c4b5b95",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['H', 'M', 'J', 'K', 'Y', 'G']"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "网三_name_list + 网三_name_list_转专业"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "a3034335",
   "metadata": {},
   "outputs": [],
   "source": [
    "age_list = [18,19,18,19,17,20,20,18,19,16,17,20]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "id": "f6f77aa8",
   "metadata": {},
   "outputs": [],
   "source": [
    "age_list.remove(19)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "id": "c384d8a9",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[18, 18, 19, 17, 20, 20, 18, 19, 16, 17, 20]"
      ]
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "age_list"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "358ed144",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
